package team.fivez.defaultmanage.utils;
//响应请求的包装类



import org.springframework.stereotype.Component;
import team.fivez.defaultmanage.domain.Result;
import team.fivez.defaultmanage.enums.ResultEnum;

@Component
public class Utils {
    /**
     * @param object object
     * @return Assemble the correct result
     */
    public static Result success(Object object) {
        Result result = new Result();
        result.setData(object);
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMessage(ResultEnum.SUCCESS.getMessage());
        return result;
    }

    /**
     * @param resultEnum resultEnum
     * @return The wrong result was assembled
     */
    public static Result error(ResultEnum resultEnum) {
        Result result = new Result();
        result.setCode(resultEnum.getCode());
        result.setMessage(resultEnum.getMessage());
        result.setData(null);
        return result;
    }

}
